import { ipcRenderer } from 'electron'
import { IpcMockKeys } from '../common/enums/ipc.mock.enum'
export interface IMockApi {
  getMockRules(): Promise<any>
  addMockRule(rule: any): Promise<any>
  updateMockRule(rule: any): Promise<any>
  deleteMockRule(id: string): Promise<any>
  toggleMockEnabled(enabled: boolean): Promise<any>
  getMockEnabled(): Promise<any>
}
export const mockApi: IMockApi = {
  // 获取所有Mock规则
  getMockRules: () => ipcRenderer.invoke(IpcMockKeys.GET_MOCK_RULES),

  // 添加新规则
  addMockRule: (rule) => ipcRenderer.invoke(IpcMockKeys.ADD_MOCK_RULES, rule),

  // 更新规则
  updateMockRule: (rule) => ipcRenderer.invoke(IpcMockKeys.UPDATA_MOCK_RULES, rule),

  // 删除规则
  deleteMockRule: (id) => ipcRenderer.invoke(IpcMockKeys.DELETE_MOCK_RULES, id),

  // 切换Mock开关
  toggleMockEnabled: (enabled) => ipcRenderer.invoke(IpcMockKeys.TOGGLE_MOCK_ENABlED, enabled),

  // 获取Mock状态
  getMockEnabled: () => ipcRenderer.invoke(IpcMockKeys.GET_MOCK_ENABlED)
}
